package gameSocketer.socketParsers
{
	import com.adobe.serialization.json.JSON;

	public class CardGameSocketPaser extends SocketParserBase
	{
		public function CardGameSocketPaser()
		{
			super();
		}
		
		override public function parseData(lengh:int=0):void{
			switch(launch.readByte()){
				case 1://///////////////////////////////////////
					var tempArr:Array = com.adobe.serialization.json.JSON.decode(launch.readUTFBytes(lengh-2))["cards_list"];
					//判断庄家牌是否是A
					if(tempArr[Math.floor(tempArr.length/2)].cardType == 13) BlackJack._gameUi.canIsume();
					for each(var tempObj:Object in tempArr){
//						tempObj =com.adobe.serialization.json.JSON.decode(tempListObj);
					BlackJack._gameUi.deal(tempObj.cardcolour,tempObj.cardType,tempObj.circleUnitID);
					}
					BlackJack._gameUi.inOneGame = true;
					break;
				case 2:
					tempObj =com.adobe.serialization.json.JSON.decode(launch.readUTFBytes(lengh-2));
					BlackJack._gameUi.deal(tempObj.cardcolour,tempObj.card,tempObj.circleUnitID);
					break;
				case 3:
					tempObj =com.adobe.serialization.json.JSON.decode(launch.readUTFBytes(lengh-2));
					BlackJack._gameUi.deal(tempObj.cardcolour,tempObj.card,tempObj.circleUnitID);
					break;
				case 5:
					tempObj =com.adobe.serialization.json.JSON.decode(launch.readUTFBytes(lengh-2));
					trace("2.5包:",tempObj.cardcolour,tempObj.card,tempObj.circleUnitID);
					BlackJack._gameUi.deal(tempObj.cardcolour,tempObj.card,tempObj.circleUnitID);
					break;
				case 6:
					tempObj =com.adobe.serialization.json.JSON.decode(launch.readUTFBytes(lengh-2));
					BlackJack._gameUi.mathGameOver(tempObj.result_list);
					break;
				case 7:
					tempObj =com.adobe.serialization.json.JSON.decode(launch.readUTFBytes(lengh-2));
					BlackJack._gameUi.tittle.txtMoney.text = tempObj.chips.toString();
					break;
				case 8:
					tempObj =com.adobe.serialization.json.JSON.decode(launch.readUTFBytes(lengh-2));
					
					break;
				case 9:
					tempObj =com.adobe.serialization.json.JSON.decode(launch.readUTFBytes(lengh-2));
					BlackJack._gameUi.changeCallCardNum(tempObj.nextcircleUnitID);
					break;
//				case 14://所有不买保险包
//					tempObj =com.adobe.serialization.json.JSON.decode(launch.readUTFBytes(lengh-2));
//					BlackJack._gameUi.changeCallCardNum(tempObj.nextcircleUnitID);
//					break;
				case 15://单个玩家买保险包
					tempObj =com.adobe.serialization.json.JSON.decode(launch.readUTFBytes(lengh-2));
					BlackJack._gameUi.resetIsumeArrow(tempObj.nextcircleUnitID);
					break;
				case 16://所有玩家买保险包
					var tempAr:Array =com.adobe.serialization.json.JSON.decode(launch.readUTFBytes(lengh-2))["list"];
//					BlackJack._gameUi.addAllIsumChip(tempAr);
					break;
				case 17://单个玩家不买保险包
					tempObj =com.adobe.serialization.json.JSON.decode(launch.readUTFBytes(lengh-2));
					BlackJack._gameUi.resetIsumeArrow(tempObj.nextcircleUnitID);
					break;
				case 18://保险结算处理包
					tempObj =com.adobe.serialization.json.JSON.decode(launch.readUTFBytes(lengh-2));
					BlackJack._gameUi.mathIsumeOver(tempObj.list);
					break;
			}
		}
	}
}